package me.hekr.iotos.softgateway.subsystem.dto;

import lombok.Data;
import me.hekr.iotos.softgateway.core.config.DeviceRemoteConfig;
import me.hekr.iotos.softgateway.core.config.DeviceRemoteConfig.Props;
import me.hekr.iotos.softgateway.core.dto.DeviceMapper;

/**
 * 广播设备
 *
 * @author iotos
 */
@Data
public class RadioDevice implements DeviceMapper {
  private static final String RADIO_DEV_ID = "radioDevId";
  /** 设备id */
  private String radioDevId;

  /** 1 在线， 0离线 */
  private int status;

  /** 音量 */
  private int vol;

  /** 播放状态 0 停止， 1 播放， 2 暂停 */
  private int playStat;

  public RadioDevice(String radioDevId) {
    this.radioDevId = radioDevId;
  }

  public RadioDevice() {}

  public static RadioDevice parse(DeviceRemoteConfig device) {
    RadioDevice dev = new RadioDevice();
    dev.setRadioDevId(device.getProp(RADIO_DEV_ID));
    return dev;
  }

  @Override
  public Props getProps() {
    return Props.p(RADIO_DEV_ID, radioDevId).get();
  }
}
